<template>
	<view class="container">
		<view>
			
			<view style="display: flex;align-items: center;justify-content: center;margin: 30rpx;">
				<image style="width: 180rpx;height: 180rpx" src="../../static/temp/gou.png"></image>
			</view>
			<view style="font-size: 36rpx;font-weight: 800;text-align: center;">导出成功</view>
			<view style="text-align: center;padding: 40rpx 100rpx;color: #808080;font-size: 28rpx;">请复制下载链接到浏览器下载</view>
			<view style="display: flex;justify-content: center;flex-direction: column;">
				<view class="btn" style="background: #23A948;color: #FFFFFF;" @click="copyLink()">复制文件下载链接</view>
				<view class="btn" style="color: #23A948;border: 1px solid #23A948;" @click="toDownloadFile()" >下载文件到微信</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import {mapMutations} from 'vuex';
	import Api from '@/common/api';
	export default{
		components: {
			
		},
		data(){
			return {
				dragon_id:0,
				download_url:'',
				name:''
			}
		},
		onLoad(){
		},
		onShow(){
			let option=this.$api.currentPageOption();
			this.dragon_id=option.id;
			this.download_url=option.download;
			this.name = option.name;
		},
		onReachBottom(){
		},
		
		methods: {
			...mapMutations(['login']),
			copyLink(){
				if(this.download_url==''||this.download_url==undefined){
					this.$api.msg(`链接异常`);
					return;
				}
				uni.setClipboardData({
					data:this.download_url,
					success:(()=>{
						uni.showToast({
							title:'复制成功'
						})
					})
				})
			},
			toDownloadFile(){
				let that =this;
				uni.downloadFile({
					url:this.download_url,
					success:((res)=>{
						uni.shareFileMessage({
							filePath:res.tempFilePath,
							fileName:this.name,
							success:(()=>{
								that.$api.msg(`分享成功`)
							}),
							fail:((err)=>{
								that.$api.msg(`分享失败`)
							})
						})
					})
				})
			},
			
		},

	}
</script>

<style lang='scss'>
	page{
		background: #fff;
	}
	.btn{
		padding: 18rpx 130rpx;
		margin: 30rpx 60rpx;
		border-radius: 10rpx;
		font-size: 30rpx;
		text-align: center;
	}
</style>
